<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>

<div class="pad-lr-10">
<form name="myform" action="?m=tasks&c=tasks&a=delete" method="post" onsubmit="checkuid();return false;">
<div class="table-list">
<table width="100%" cellspacing="0">
	<thead>
		<tr>
			<th  align="left" width="20"><input type="checkbox" value="" id="check_box" onclick="selectall('taskid[]');"></th>
			<th align="left">任务ID</th>
			<th align="left">任务类型</th>
			<th align="left">任务名称</th>
			<th align="left">间隔时间</th>
			<th align="left">运行状态</th>
			<th align="left">启动时间</th>
			<th align="left">任务说明</th>
			<th align="left">可用操作</th>
		</tr>
	</thead>
<tbody>
<?php
	foreach($tasks as $k=>$v) {
?>
    <tr>
		<td align="left"><input type="checkbox" value="<?php echo $v['taskid']?>" name="taskid[]"></td>
		<td align="left"><?php echo $v['taskid']?></td>
		<td align="left"><?php echo tasktype($v['tasktype'])?></td>
		<td align="left"><?php echo $v['taskname']?></td>
		<td align="left"><?php echo $v['tasktime']?>分钟</td>
		<td align="left"><?php
		if ($v['taskon'] == 0) {
			?><font color="#FF0000">任务暂停中</font><?
		} else {
			$rtime = time () - $v ['addtime'];
			$rday = floor ( $rtime / (60 * 60 * 24) );
			$rhour = floor ( $rtime / (60 * 60) );
			$rmin = floor ( ($rtime / 60) % 60 );
			echo $rday . " 天 " . $rhour . " 小时 " . $rmin . " 分钟 ";
			if ($v['taskswitch'] == 0)
			echo "（等待停止）";
		}
		?></td>
		<td align="left"><?php
		$ftime = floor ( (time () - $v['addtime']) / 86400 );
		if ($ftime < 11) {
			if ($ftime == 0) {
				echo '今天' . date ( "H:i:s", $v['addtime'] );
			}
			if ($ftime == 1) {
				echo '昨天' . date ( "H:i:s", $v['addtime'] );
			}
			if ($ftime > 1)
				echo $ftime . '天前' . date ( "H:i:s", $v ['addtime'] );
		} else {
			echo date ( "Y-m-d H:i:s", $v ['addtime'] );
		}
		?></td>
		<td align="left"><?php echo $v ['info']?></td>
		<td align="left">
		<? if ($v['taskon'] == 0) {?>
            <a href="?m=tasks&c=tasks&a=start&taskid=<? echo $v['taskid'];?>">启动</a>
        <? } else { ?>
            <a href="?m=tasks&c=tasks&a=stop&taskid=<? echo $v['taskid']; ?>">暂停</a> 
        <? }?>
			<a href="?m=tasks&c=tasks&a=edit&taskid=<? echo $v['taskid']; ?>">编辑</a> <a href="?m=tasks&c=tasks&a=log&taskid=<? echo $v['taskid'];?>">日志</a></td>
    </tr>
<?php
	}
?>
</tbody>
</table>
<div class="btn">
<label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onclick="return confirm('<?php echo L('sure_delete')?>')"/>
</div>
<div id="pages"><?php echo $pages?></div>
</div>
</form>
</div>
<script type="text/javascript">
<!--
function checkuid() {
	var ids='';
	$("input[name='taskid[]']:checked").each(function(i, n){
		ids += $(n).val() + ',';
	});
	if(ids=='') {
		window.top.art.dialog({content:'<?php echo L('plsease_select').L('tasks')?>',lock:true,width:'200',height:'50',time:1.5},function(){});
		return false;
	} else {
		myform.submit();
	}
}
//-->
</script>
</body>
</html>